﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace Tcvt.Packages
{
    public partial class WorkspacesForm : Form
    {
        private int _selectedWorkspaceIndex = -1;
        private WorkspaceInfo[] _workspaces;

        public WorkspacesForm()
        {
            InitializeComponent();
        }

        private void AddSelectedWorkspaceButton_Click(object sender, EventArgs e)
        {
            if (WorkspacesListBox.SelectedIndex >= 0)
            {
                _selectedWorkspaceIndex = WorkspacesListBox.SelectedIndex;
                this.Close();
            }
            else
            {
                Utils.ShowErrorMessageBox("Please select a workspace.");
            }
        }

        private void CancelWorkspaceButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void WorkspacesForm_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < _workspaces.Length; i++)
            {
                WorkspacesListBox.Items.Add(_workspaces[i].Name);
            }
        }

        public WorkspaceInfo[] Workspaces
        {
            get
            {
                return _workspaces;
            }
            set
            {
                _workspaces = value;
            }
        }

        public int SelectedWorkspaceIndex
        {
            get
            {
                return _selectedWorkspaceIndex;
            }
            set
            {
                _selectedWorkspaceIndex = value;
            }
        }

        private void WorkspacesListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (WorkspacesListBox.SelectedIndex >= 0)
                this.AddSelectedWorkspaceButton.Enabled = true;
        }


    }
}
